package com.ruoyi.basedata.api.factory;

import com.ruoyi.basedata.api.RemoteGoodsService;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.system.api.domain.basedata.Goods;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

import java.math.BigDecimal;
import java.util.List;

@Component
public class RemoteGoodsFallbackFactory implements FallbackFactory<RemoteGoodsService> {

    @Override
    public RemoteGoodsService create(Throwable cause) {
        return new RemoteGoodsService() {

            @Override
            public R<List<Goods>> getGoodsListByIds(List<Integer> ids, String source) {
                return R.fail("请求失败");
            }

            @Override
            public R<Goods> getGoodsById(Integer id) {
                return R.fail("请求失败");
            }

            @Override
            public R<BigDecimal> getCostByGoodsId(Integer id) {
                return R.fail("请求失败");
            }

            @Override
            public AjaxResult edit(Goods goods) {
                return AjaxResult.error("请求失败");
            }
        };
    }
}
